package com.finchina.myview;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.finchina.myview.androidviewhelpers.JellyTextView;

/**
 * <b>Project:</b> My View<br>
 * <b>Create Date:</b> 2016/1/21<br>
 * <b>Author:</b> huang saisai<br>
 * <b>Description:</b> <br>
 */
public class OverScrollerActivity extends AppCompatActivity implements View.OnClickListener{
    JellyTextView jetv;
    int distance = 0;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_overscroller);
        findViewById(R.id.button).setOnClickListener(this);
        findViewById(R.id.button2).setOnClickListener(this);
        findViewById(R.id.button3).setOnClickListener(this);
        jetv = (JellyTextView) findViewById(R.id.jetv);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button:
                distance += 10;
                jetv.scrollTo(distance, 0);

                break;
            case R.id.button2:
//                jetv.scrollBy(30, 0);

                distance -= 10;
                jetv.scrollTo(distance, 0);

                break;
            case R.id.button3:
                //不知道为什么第一次调用会贴墙，即到达x=0的位置
                jetv.spingBack();
                break;
        }
    }
}
